<%@ page import="util.DBUtil" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/10/13
  Time: 10:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户信息管理</title>
</head>
<body>
    <h3>用户信息管理</h3>
    <form>
        关键词：<input type="text"  name="keyword"/>
              <input type="submit"  value="查询"/>
    </form>
   <p>
       <a href="user_add.jsp"> +新增用户 </a>
        <table>
          <thead>
             <tr><td>id</td>  <td>用户名</td>  <td>操作</td></tr>
          </thead>
          <tbody>
            <%
                /*从数据库的用户表中获取所有的用户数据，进行显示*/
                DBUtil dbUtil =new DBUtil();
                String sql ="select * from tb_user";
                ResultSet rs=dbUtil.query(sql);
                while (rs.next()){
                    out.println("<tr>");
                    out.println("<td>"+rs.getInt("id")+"</td>");
                    out.println("<td>"+rs.getString("username")+"</td>");
                    out.println("<td>"
                            +"<a href=\"user_del.jsp?id="+rs.getInt("id")+"\"  onclick=\"return  confirm('您确定要删除吗？')\">删除</a>"
                            +"</td>");
                    out.println("</tr>");
                }
                dbUtil.close();
            %>

          </tbody>
    </table>
   </p>


</body>
</html>
